﻿using System;
using JiaBao.Core;
using JiaBao.Core.Data;

namespace JiaBao.Data
{
    public class EfDataProviderManager : BaseDataProviderManager
    {
        public EfDataProviderManager(DataSettings settings) : base(settings)
        {
        }

        public override IDataProvider LoadDataPrvider()
        {
            var providerName = Settings.DataProvider;
            if (String.IsNullOrWhiteSpace(providerName))
                throw new JiaBaoException("数据设置不包含providerName");
            switch (providerName)
            {
                case "sqlserver":
                    return new SqlServerDataProvider();

                default:
                    throw new JiaBaoException("不支持的数据提供者名称：{0}", providerName);
            }
        }
    }
}
